<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Proxy代理对象的使用</title>
</head>
<body>
<script>
    class Person {
        //_标识私有
        _id = 0;
        _name = '向妙';
        _sex = '女';
        _birthday = new Date();
        _address = '张家界市桑植县';

        //构造方法
        constructor() {
            return this;
        }

        //toString
        toString() {
            return this._id + this._name + this._sex + this._address;
        }

        // get id() {
        //     return this._id;
        // }
        //
        // set id(value) {
        //     this._id = value;
        // }
        //
        // get name() {
        //     return this._name;
        // }
        //
        // set name(value) {
        //     this._name = value;
        // }
        //
        // get sex() {
        //     return this._sex;
        // }
        //
        // set sex(value) {
        //     this._sex = value;
        // }
        //
        // get birthday() {
        //     return this._birthday;
        // }
        //
        // set birthday(value) {
        //     this._birthday = value;
        // }
        //
        // get address() {
        //     return this._address;
        // }
        //
        // set address(value) {
        //     this._address = value;
        // }
    }

    let person = new Person();
    let objs = [];
    let proxy = new Proxy(person, {
        get(target, p, receiver) {
            console.log(target);
            console.log(p)
            console.log(receiver)
            objs.push(target);
            objs.push(p);
            objs.push(receiver);
            objs.push("=============")
        },
        set(target, p, value, receiver) {
            console.log(target);
            console.log(p);
            console.log(value);
            console.log(receiver);
            objs.push(target);
            objs.push(p);
            objs.push(value);
            objs.push(receiver);
        }
    });
    objs.push(proxy._id);
    objs.push(proxy._name);
    objs.push(proxy._birthday);
    objs.push(proxy._address);
    // console.log(person)
    // console.log(proxy)
    console.log(objs)
</script>
</body>
</html>